/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.dahg.project.istu.controller.bean.commons;

import com.dahg.project.istu.controller.bean.AbstractSingleEntityBean;
import com.dahg.project.istu.controller.services.IServiceCatalogo;
import java.util.List;
import javax.persistence.TypedQuery;

/**
 *
 * @author Jose 
 * @param <T> 
 */
public abstract class AbstractCatalogoService<T extends ICatalogo> extends AbstractSingleEntityBean<T> implements IServiceCatalogo<T> {
    
    @Override
    public List<T> getAll() {
        /*
        Equivalente a: select obj from MiObj obj
        */
        TypedQuery<T> typedQuery = getTypedQuery(getSelectCriteriaQuery());        
        return typedQuery.getResultList();
    }    

    @Override
    public List<T> searchForName(String name) {
        return searchFor(name+"%", "nombre");
    }
    
}
